Arduino If ... else if ... else语句

您所在的位置:网站首页 vb中if else怎么用 Arduino If ... else if ... else语句

Arduino If ... else if ... else语句

2023-11-27 05:00| 来源: 网络整理| 查看: 265

if 语句后面可以跟随一个可选的 else if ... else 语句,其对于测试各种条件非常有用。

当使用 if ... else if ... else 语句时,请记住:

一个 if 可以有0或一个else语句,它必须在所有else if之后。

if 可以有0到多个else if语句,它们必须在else之前。

一旦 else if 成功,将不会测试剩余的else if或else语句。

if ... else if ... else语句if (expression_1) { Block of statements; } else if(expression_2) { Block of statements; } . . . else { Block of statements; }if ... else if ... else语句执行顺序if ... else if ... else语句执行顺序例子/* Global variable definition */ int A = 5 ; int B = 9 ; int c = 15; Void setup () { } Void loop () { /* check the boolean condition */ if (A > B) /* if condition is true then execute the following statement*/ { A++; } /* check the boolean condition */ else if ((A == B )||( B < c) ) /* if condition is true then execute the following statement*/ { C = B* A; }else c++; }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3